import router from "./router";

router.beforeEach(async (to, from, next) => {
  const whiteList = ["/login"];

  const token = localStorage.getItem("token");
  if (!token) {
    if (to.path === "/login") {
      next("/");
    } else {
      next();
    }
  } else {
    if (whiteList.includes(to.path)) {
      next();
    } else {
      next("/login");
    }
  }
});
// router.afterEach(() => {
//   NPro
// })
